PDF顺时针旋转固定角度
from PyPDF2 import PdfFileReader, PdfFileWriter
def pdf_rotate(raw_path, save_path, angle=90):
"""
将 PDF 顺时针旋转固定角度
:param raw_path: PDF原文件路径
:param save_path: 旋转后PDF保存路径
:param angle: 旋转角度
:return:
"""
read_pdf = PdfFileReader(raw_path)
write_pdf = PdfFileWriter()
page_0 = read_pdf.getPage(0).rotateClockwise(angle) # 顺时针旋转angle度
write_pdf.addPage(page_0)
with open(save_path, "wb") as f:
write_pdf.write(f)